home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / misc / football / exec / readmatchdata.rexx < prev    next >
OS/2 REXX Batch file  |  1999-11-29  |  5KB  |  148 lines

  1. /* ***********************************************************************
  2.  
  3.    READ MATCH DATA PROGRAM FOR FOOTBALL REXX SUITE
  4.   -------------------------------------------------
  5.                    Copyright  Mark Naughton 1999
  6.  
  7.  
  8. Version    Date     History
  9. --------------------------------------------------------------------------
  10.  
  11.  1.0       240999   Created. Reads data for a match using match number.
  12.            021099   Bug fixed where the code would interpret the attendance
  13.                     as an away match stat - reported by Heiko Schroder.
  14.  
  15. **************************************************************************
  16.  
  17. Procedure
  18. ---------
  19.  
  20. 1. Split argument into league-name and match.
  21. 2. Check schedule learn file exists. Delete output file if it exists.
  22. 3. Read learn file, checking until the match number is found. When it is,
  23.    read the data, splitting it into different types and store in an array.
  24. 4. If we have some data to write, write to the temporary file. Exit.
  25.  
  26. ************************************************************************** */
  27. PARSE ARG league_stuff
  28.  
  29. version      = 1
  30. input_file   = '.sflearn'
  31. separator    = '*'
  32. sdlines.     = '???'
  33. sdcount      = 0
  34.  
  35.  
  36. parse var league_stuff league_file mkr
  37. league_file  = "Data/"league_file
  38.  
  39. if exists(league_file || input_file) = 0 then
  40.    exit
  41.  
  42. if mkr < 0 then exit
  43.  
  44. output_file = "RAM:ReadMatchData.temp"
  45.  
  46. if exists(output_file) > 0 then
  47.    address command 'c:Delete >NIL: 'output_file
  48.  
  49. mkm = 0
  50. mka = 0
  51. if open(datafile3,league_file || input_file,'r') then do
  52.    do while ~eof(datafile3)
  53.       line = readln(datafile3)
  54.       if pos(separator,line) = 0 then
  55.          mkm = mkm + 1
  56.       if mkm > mkr then
  57.          mka = 0
  58.       if mkm = mkr & mka = 0 then do
  59.          mka = 1
  60.          sdcount = sdcount + 1
  61.          sdlines.sdcount = "*HO="strip(substr(line,1,30))
  62.          sdcount = sdcount + 1
  63.          sdlines.sdcount = "*AW="strip(substr(line,41,30))
  64.          sdcount = sdcount + 1
  65.          sdlines.sdcount = "*SH="strip(substr(line,32,2))
  66.          sdcount = sdcount + 1
  67.          sdlines.sdcount = "*SA="strip(substr(line,37,2))
  68.       end
  69.       if mka = 1 then do
  70.          if pos("*H",line) > 0 | (pos("*A",line) > 0 & pos("*ATD",line) = 0) then do
  71.             tim = ""
  72.             typ = 0
  73.             if pos("(P)",line) > 0 then typ = 1
  74.             if pos("(og)",line) > 0 then typ = 2
  75.             if typ ~= 0 then do
  76.                l1 = strip(word(line,words(line)-1,1))
  77.                if datatype(l1) = "NUM" then do
  78.                   tim = l1
  79.                   line = strip(delword(line,words(line)))
  80.                end
  81.                line = strip(delword(line,words(line),1))
  82.             end
  83.             if typ = 0 then do
  84.                l2 = strip(word(line,words(line),1))
  85.                if datatype(l2) = "NUM" then do
  86.                   tim = l2
  87.                   line = strip(delword(line,words(line),1))
  88.                end
  89.             end
  90.             if pos("Y=",line) > 0 then  typ = 3
  91.             if pos("YR=",line) > 0 then typ = 4
  92.             if pos("HR=",line) > 0 then typ = 5
  93.             if pos("AR=",line) > 0 then typ = 5
  94.             if pos("S=",line) > 0 then  typ = 6
  95.             if pos("M=",line) > 0 then  typ = 7
  96.  
  97.             if pos("*H",line) > 0 then do
  98.                parse var line "*H" . "=" player
  99.                sdcount = sdcount + 1
  100.                sdlines.sdcount = "*HP="strip(player)
  101.                if tim ~= "" then do
  102.                   sdcount = sdcount + 1
  103.                   sdlines.sdcount = "*HMM="tim
  104.                end
  105.                sdcount = sdcount + 1
  106.                sdlines.sdcount = "*HTYP="typ
  107.             end
  108.             if pos("*A",line) > 0 then do
  109.                parse var line "*A" . "=" player
  110.                sdcount = sdcount + 1
  111.                sdlines.sdcount = "*AP="strip(player)
  112.                if tim ~= "" then do
  113.                   sdcount = sdcount + 1
  114.                   sdlines.sdcount = "*AMM="tim
  115.                end
  116.                sdcount = sdcount + 1
  117.                sdlines.sdcount = "*ATYP="typ
  118.             end
  119.          end
  120.          if pos("*RF=",line) > 0 then do
  121.             sdcount = sdcount + 1
  122.             sdlines.sdcount = strip(line)
  123.          end
  124.          if pos("*ATD=",line) > 0 then do
  125.             sdcount = sdcount + 1
  126.             sdlines.sdcount = strip(line)
  127.          end
  128.       end
  129.       if mkm > mkr then do    /* exit when we've read our data */
  130.          leave
  131.       end
  132.    end
  133.    close(datafile3)
  134. end
  135.  
  136. if sdcount > 0 then do
  137.    if open(datafile2,output_file,'w') then do
  138.       do i=1 to sdcount
  139.          if sdlines.i ~= "" | sdlines.i ~= "???" then
  140.             writeln(datafile2,strip(sdlines.i))
  141.       end
  142.       close(datafile2)
  143.    end
  144. end
  145.  
  146. exit
  147.  
  148. /* *********************************************************************** */